package demo1.Factory;

import demo1.Factory.product.Product;
import demo1.Factory.product.Product1;
import demo1.Factory.product.impl.ConcreteProductA;
import demo1.Factory.product.impl.ConcreteProductB;
import demo1.Teacher;

/**
 * @ClassName SimpleFactory
 * @Description TODO
 * @Author 耀酱
 * @Date 2023/6/2 10:43
 * @Version 1.0
 */

public class SimpleFactory {

    public static Product1 getProduct(String type){
        switch (type) {
            case "A":
                return new ConcreteProductA();
            case "B":
                return new ConcreteProductB();
            default:
                throw new IllegalArgumentException("Unknown product type: " + type);
        }
    }
    public static void main(String[] args) {

        Product1 a = SimpleFactory.getProduct("A");
        a.append1();

        // 可以采用反射机制动态的创建对象

    }
}
